home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performRebuildCurve.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.2 KB  |  385 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 14, 1997
  22. //  Author:         laf 
  23. //
  24. //  Description:
  25. //      This script is defines the option box for the rebuild curve menu item.
  26. //
  27.  
  28.  
  29. //
  30. //  Procedure Name:
  31. //      setOptionVars
  32. //
  33. //  Description:
  34. //        Initialize the option values.
  35. //
  36. //  Input Arguments:
  37. //        Whether to set the options to default values.
  38. //
  39. //  Return Value:
  40. //      None.
  41. //
  42. proc setOptionVars(int $forceFactorySettings)
  43. {
  44.     rebuildCurveSetOptionVars( $forceFactorySettings );
  45. }
  46.  
  47. global proc rebuildCurveSetupLocal( string $parent,
  48.                                     int $forceFactorySettings,
  49.                                     string $goToTool )
  50. {
  51.     //    Retrieve the option settings
  52.     //
  53.     setOptionVars($forceFactorySettings);
  54.     rebuildCurveToolSetup( $forceFactorySettings, $goToTool );
  55.  
  56.     setParent $parent;
  57.  
  58.     //    Query the optionVar's and set the values into the controls.
  59.  
  60.     int $useGlobalTol = `optionVar -query rebuildCurveUseGlobalTolerance`;
  61.     radioButtonGrp -e -select (2 - $useGlobalTol) toleranceRadioButtonGrp;
  62.  
  63.     float $localTol = `optionVar -query rebuildCurveLocalTolerance`;
  64.     int $keepOriginal = `optionVar -query rebuildCurveKeepOriginal`;
  65.  
  66.  
  67.     radioButtonGrp -edit -select $useGlobalTol toleranceRadioButtonGrp;
  68.     floatSliderGrp -edit -value $localTol localTolFloatFieldGrp;
  69.  
  70.     if( `checkBoxGrp -q -exists keepOriginalCheckBox` ) {
  71.         checkBoxGrp -edit -value1 $keepOriginal keepOriginalCheckBox;
  72.     }
  73.  
  74.     rebuildCurveSetup( $parent, $forceFactorySettings );
  75.  
  76.     if( "" != $goToTool ) { 
  77.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  78.           scriptToolExtraWidget;
  79.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  80.           scriptToolExtraWidget;
  81.     }
  82. }
  83.  
  84. //
  85. //  Procedure Name:
  86. //      rebuildCurveOptions
  87. //
  88. //  Description:
  89. //        Construct the option box UI.  Involves accessing the standard option
  90. //        box and customizing the UI accordingly.
  91. //
  92. //  Input Arguments:
  93. //      None.
  94. //
  95. //  Return Value:
  96. //      None.
  97. //
  98.  
  99. proc rebuildCurveOptions( int $inTheTool, string $goToTool )
  100. {
  101.     //    Name of the command for this option box.
  102.     //
  103.     string $commandName = "rebuildCurve";
  104.  
  105.     //    Build the option box actions.
  106.     //
  107.     string $callback = ($commandName + "Callback");
  108.     string $setup = ($commandName + "SetupLocal");
  109.  
  110.     global string $gOptionBoxActionToolItem;
  111.     $gOptionBoxActionToolItem = "modelWithToolRebuildCurve";
  112.     global string $gOptionBoxActionToolItemCB;
  113.     $gOptionBoxActionToolItemCB = "rebuildCurveToolScript 3";
  114.  
  115.     //    Step 1:  Get the option box.
  116.     //    ============================
  117.     string $layout = getOptionBox();
  118.     setParent $layout;
  119.     
  120.     //    Step 2:  Pass the command name to the option box.
  121.     //    =================================================
  122.     setOptionBoxCommandName($commandName);
  123.     
  124.     //    Step 3:  Activate the default UI template.
  125.     //    ==========================================
  126.     setUITemplate -pushTemplate DefaultTemplate;
  127.  
  128.     //    Step 4: Create option box contents.
  129.     //    ===================================
  130.     
  131.     //    Turn on the wait cursor.
  132.     //
  133.     waitCursor -state 1;
  134.  
  135.     tabLayout -scr true -tv false;
  136.     
  137.     string $parent = `columnLayout -adjustableColumn 1`;
  138.     
  139.     rebuildCurveAddOptions( $parent, 1 );
  140.  
  141.     if( $inTheTool ) {
  142.         separator;
  143.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  144.           -l1 "Exit on Completion"
  145.           -v1 off
  146.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  147.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  148.  
  149.           -l2 "Auto Completion"
  150.           -v2 on
  151.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  152.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  153.           scriptToolExtraWidget;
  154.     }
  155.  
  156.     //    Turn off the wait cursor.
  157.     //
  158.     waitCursor -state 0;
  159.     
  160.     //    Step 5: Deactivate the default UI template.
  161.     //  ===========================================
  162.     //
  163.     setUITemplate -popTemplate;
  164.  
  165.     //    Step 6: Customize the buttons.  
  166.     //    ==============================
  167.  
  168.     //    'Apply' button.
  169.     //
  170.     string $applyBtn = getOptionBoxApplyBtn();
  171.     if( $inTheTool ) {
  172.         button -edit -l "Rebuild Tool"
  173.             -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  174.             $applyBtn;
  175.     }
  176.     else {
  177.         button -edit -l "Rebuild"
  178.             -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  179.             $applyBtn;
  180.     }
  181.  
  182.     //    'Save' button.
  183.     //
  184.     string $saveBtn = getOptionBoxSaveBtn();
  185.     button -edit 
  186.         -command ($callback + " " + $parent + " 0 \"" +
  187.                   $goToTool + "\"; hideOptionBox")
  188.         $saveBtn;
  189.  
  190.     //    'Reset' button.
  191.     //
  192.     string $resetBtn = getOptionBoxResetBtn();
  193.     button -edit 
  194.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  195.         $resetBtn;
  196.  
  197.     //    Step 7: Set the option box title.
  198.     //    =================================
  199.     //
  200.     if( $inTheTool ) {
  201.         setOptionBoxTitle("Rebuild Curve Tool Options");
  202.     }
  203.     else {
  204.         setOptionBoxTitle("Rebuild Curve Options");
  205.     }
  206.  
  207.     //    Step 8: Customize the 'Help' menu item text.
  208.     //    ============================================
  209.     //
  210.     setOptionBoxHelpTag( "RebuildCurve" );
  211.  
  212.     //    Step 9: Set the current values of the option box.
  213.     //    =================================================
  214.     //
  215.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  216.     
  217.     //    Step 10: Show the option box.
  218.     //    =============================
  219.     //
  220.     showOptionBox();
  221. }
  222.  
  223. //
  224. //  Procedure Name:
  225. //      rebuildCurveHelp
  226. //
  227. //  Description:
  228. //        Return a short description about this command.
  229. //
  230. //  Input Arguments:
  231. //      None.
  232. //
  233. //  Return Value:
  234. //      string.
  235. //
  236.  
  237. proc string rebuildCurveHelp()
  238. {
  239.     return 
  240.     "  Command: Rebuild Curve - perform curve rebuild\n" +
  241.     "Selection: curve, curve on surface";    
  242. }
  243.  
  244. global proc performRebuildCurvePreset()
  245. {
  246.     rebuildCurveSetOptionVars( false );
  247.  
  248.     int $doHistory = `constructionHistory -q -tgl`;
  249.     int $replaceOriginal = !`optionVar -q rebuildCurveKeepOriginal`;
  250.     int $rebuildType = `optionVar -q rebuildCurveType`;
  251.     float $globalTol = `optionVar -q positionalTolerance`;
  252.  
  253.     int $crvNumSpans = `optionVar -q rebuildCurveTypeUniformNumSpans`;
  254.     int $crvDegree = `optionVar -q rebuildCurveTypeUniformDegree`;
  255.     int $keepParmRange = `optionVar -q rebuildCurveKeepRange`;
  256.     int $endKnots = `optionVar -q rebuildCurveEndKnots`;
  257.     int $keepControlPoints = `optionVar -q rebuildCurveKeepControlPoints`;
  258.     int $keepEndPts = `optionVar -q rebuildCurveKeepEndPoints`;
  259.     int $keepTan = `optionVar -q rebuildCurveKeepEndTangents`;
  260.     int $keepNumSpans = `optionVar -q rebuildCurveKeepNumSpans`;
  261.     int $crvUseGlobalTol = `optionVar -q rebuildCurveUseGlobalTolerance`;
  262.     float $crvLocalTol = `optionVar -q rebuildCurveLocalTolerance`;
  263.  
  264.     // 0 means keep the existing number of spans
  265.     if( $keepNumSpans ) {
  266.         $crvNumSpans = 0;
  267.     }
  268.  
  269.     performRebuildCurveSet( $doHistory, $replaceOriginal,
  270.                             $rebuildType, $globalTol,
  271.                             $crvNumSpans, $crvDegree,
  272.                             $endKnots,
  273.                             $keepParmRange, $keepControlPoints,
  274.                             $keepEndPts, $keepTan,
  275.                             $crvUseGlobalTol, $crvLocalTol );
  276. }
  277.  
  278. //
  279. //  Procedure Name:
  280. //      assembleCmd
  281. //
  282. //  Description:
  283. //        Construct the command that will apply the option box values.
  284. //
  285. //  Input Arguments:
  286. //      None.
  287. //
  288. //  Return Value:
  289. //      None.
  290. //
  291. proc string assembleCmd()
  292. {
  293.     string $cmd = "performRebuildCurveSet";
  294.  
  295.     setOptionVars(false);
  296.  
  297.     int $doHistory = `constructionHistory -q -tgl`;
  298.     int $replaceOriginal = !`optionVar -q rebuildCurveKeepOriginal`;
  299.     int $rebuildType = `optionVar -q rebuildCurveType`;
  300.     float $globalTol = `optionVar -q positionalTolerance`;;
  301.  
  302.     int $crvNumSpans = `optionVar -q rebuildCurveTypeUniformNumSpans`;
  303.     int $crvDegree = `optionVar -q rebuildCurveTypeUniformDegree`;
  304.     int $keepParmRange = `optionVar -q rebuildCurveKeepRange`;
  305.     int $endKnots = `optionVar -q rebuildCurveEndKnots`;
  306.     int $keepControlPoints = `optionVar -q rebuildCurveKeepControlPoints`;
  307.     int $keepEndPts = `optionVar -q rebuildCurveKeepEndPoints`;
  308.     int $keepTan = `optionVar -q rebuildCurveKeepEndTangents`;
  309.     int $keepNumSpans = `optionVar -q rebuildCurveKeepNumSpans`;
  310.     int $crvUseGlobalTol = `optionVar -q rebuildCurveUseGlobalTolerance`;
  311.     float $crvLocalTol = `optionVar -q rebuildCurveLocalTolerance`;
  312.  
  313.     // 0 means keep the existing number of spans
  314.     if( $keepNumSpans ) {
  315.         $crvNumSpans = 0;
  316.     }
  317.  
  318.     $cmd = ( $cmd + " " +
  319.              $doHistory + " " +
  320.              $replaceOriginal + " " +
  321.              $rebuildType + " " +
  322.              $globalTol + " " +
  323.              $crvNumSpans + " " +
  324.              $crvDegree + " " +
  325.              $endKnots + " " +
  326.              $keepParmRange + " " +
  327.              $keepControlPoints + " " +
  328.              $keepEndPts + " " +
  329.              $keepTan + " " +
  330.              $crvUseGlobalTol + " " +
  331.              $crvLocalTol );
  332.     return $cmd;
  333. }
  334.  
  335. //
  336. //  Procedure Name:
  337. //      performRebuildCurve
  338. //
  339. //  Description:
  340. //        Perform the rebuildCurve command using the corresponding 
  341. //        option values.  This procedure will also show the option box
  342. //        window if necessary as well as construct the command string
  343. //        that will invoke the rebuildCurve command with the current
  344. //        option box values.
  345. //
  346. //  Input Arguments:
  347. //      0 - Execute the command.
  348. //      1 - Show the option box dialog.
  349. //      2 - Return the command.
  350. //
  351. //  Return Value:
  352. //      None.
  353. //
  354.  
  355. global proc string performRebuildCurve(int $action, string $goToTool )
  356. {
  357.     int $inTheTool = false;
  358.     if( 3 == $action ) {
  359.         $action = 1;
  360.         $inTheTool = true;
  361.     }
  362.  
  363.     string $cmd = "";
  364.     switch ($action) {
  365.  
  366.       case 0:
  367.         setOptionVars(false);
  368.         $cmd = `assembleCmd`;
  369.         eval($cmd);
  370.         break;
  371.  
  372.       case 1:
  373.         rebuildCurveOptions( $inTheTool, $goToTool );
  374.         break;
  375.  
  376.       case 2:
  377.       default:
  378.         setOptionVars (false);
  379.         $cmd = `assembleCmd`;
  380.         break;
  381.     }
  382.     return $cmd;
  383. }
  384.  
  385.